(println "loading")
(ns use-fx-clj.example2
  (:require [fx-clj.core :as fx]
            [clojure.core.async :refer [chan go <! >!]])
  (:import (javafx.application Platform)))

(defn create-view []
  (let [click-ch (chan)
        btn (fx/button :#my-btn {:on-action click-ch
                                 :text      "Next"})
        txt (fx/text "Initial text")
        view (fx/v-box txt btn)]
    (go
      (let [a (<! click-ch)]
        (println a)
        (fx/run<! (fx/pset! txt "Next text")))
      (let [b (<! click-ch)]
        (println b)
        (fx/run<!
          (fx/pset! txt "Last text")
          (fx/pset! btn {:text "Done"})))
      (println "Done listening to clicks"))
    view))

(println (create-view))

(Platform/setImplicitExit true)
(println "loading...")
(fx/sandbox #'create-view)
(println "load done")